﻿using Api.WDS.Methods;
using Method.DAL;
using Models.operResult;
using Models.VModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Api.WDS.Operate
{
    public class DisplayOp
    {
        //获取当前用户文章集合
        public OperResult<List<V_ArticleList>> GetUserArticleList(string token, string index)
        {
            var uid = new GetUidByToken().GetUid(token);
            if (uid is null)
                return OperResult<List<V_ArticleList>>.Failed("请重新登录");
            if (!int.TryParse(index, out int i))
                return OperResult<List<V_ArticleList>>.Succeed(new List<V_ArticleList>());
            var data = new DisplayMet().GetUserArticles(Convert.ToInt32(uid), Convert.ToInt32(index));
            if (data is null)
                return OperResult<List<V_ArticleList>>.Failed("获取用户文章失败");
            return OperResult<List<V_ArticleList>>.Succeed(data);
        }
    }
}
